import datetime
import json
from decimal import Decimal

import pymysql
from PySide6 import QtCore, QtGui
from PySide6.QtGui import QAction, QKeySequence, QShortcut, QIcon, QPalette
from PySide6.QtWidgets import QMainWindow, QTableWidget, QTableWidgetItem, QHeaderView, QAbstractItemView, QStatusBar, \
    QMenu, QApplication, QWidget, QMessageBox, QTextEdit
from PySide6.QtCore import Qt, QPoint, Slot, QEvent

from controllers.loading import LoadingMask
from global_variables import GlobalVariables
from util import common
from util.common import hum_convert


class HistoryListFillData(QMainWindow):
    def __init__(self, app):
        super().__init__()
        self.app = app
        self.ui = app.ui
        self.init()

    def init(self):
        pass

    # 添加历史记录至视图
    def add_history_to_view(self):
        history_str = self.get_history_from_file()
        self.ui.history_text_edit: QTextEdit
        self.ui.history_text_edit.setWordWrapMode(QtGui.QTextOption.WrapMode.WrapAnywhere)
        self.ui.history_text_edit.setText(history_str)
        self.ui.history_text_edit.moveCursor(QtGui.QTextCursor.End)

    def get_history_from_file(self):
        from util.history_file import read as history_file_read
        return history_file_read()
